package com.gxa.admin.recycling.controller;


import com.gxa.admin.recycling.service.MemberLevelService;
import com.gxa.core.recycling.common.JsonResult;
import com.gxa.core.recycling.pojo.MemberLevel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/memberLevel")

@Api(tags = "用户等级")
public class MemberLevelController {

    @Autowired
    private MemberLevelService memberLevelService;

    @PostMapping("/findMemberLevel")
    @ApiOperation("查询全部用户等级")
    public Map findAll(){

        List<MemberLevel> list = memberLevelService.selectAll();

        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("200");

        jsonResult.setData(list);
        return jsonResult.getDataMap();

    }

    @PostMapping("/updateMemberLevel")
    @ApiOperation("修改用户等级")
    public Map updateMemberLevel(@RequestBody MemberLevel memberLevel){

        memberLevelService.updateById(memberLevel);
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("200");

        return jsonResult.getDataMap();
    }
}
